#include"Sort.h"
#include"Stack.h"
void test()
{
	int arr[] = { 1,4,7,8,9,5,6,3,0,1,};
	int sz = sizeof(arr) / sizeof(arr[0]);
	PrintArray(arr, sz);
	SelectSort(arr, sz);
	//HeapSort(arr, sz);
	//InsertSort(arr, sz);
	//ShellSort(arr, sz);
	//QuickSort(arr, 0, sz - 1);
	//QuickSortNonR(arr, 0, sz - 1);
	PrintArray(arr, sz);
}
void testQuickSort()
{
	int N = 1000000;
	int* arr = (int*)malloc(sizeof(int) * N);
	int* arr2 = (int*)malloc(sizeof(int) * N);
	if (arr == NULL)
	{
		perror("testShellSort->malloc failed");
		exit(-1);
	}
	if (arr2 == NULL)
	{
		perror("testShellSort->malloc failed");
		exit(-1);
	}
	for (int i = 0; i < N; i++)
	{
		arr[i] = rand();
		arr2[i] = arr[i];
	}
	//PrintArray(arr, N);
	//ShellSort(arr, N);
	//PrintArray(arr, N);
	int begin1 = clock();
	QuickSort(arr, 0, N - 1);
	int end1 = clock();
	printf("QuickSort:%d\n", end1 - begin1);
	int begin2 = clock();
	QuickSortNonR(arr2, 0, N - 1);
	printf("QuickSortNonR:%d\n", end1 - begin1);
	int end2 = clock();

	free(arr);
	free(arr2);
}

void testStack()
{
	ST st;
	StackInit(&st);
	StackPush(&st, 1);
	StackPush(&st, 2);
	StackPush(&st, 3);
	StackPush(&st, 4);
	while (!StackEmpty(&st))
	{
		printf("%d\n", StackTop(&st));
		StackPop(&st);
	}

	StackDestroy(&st);
}
void testShellSort()
{

}
void test1()
{
	int N = 30;
	int* arr = (int*)malloc(sizeof(int) * N);
	//int* arr2 = (int*)malloc(sizeof(int) * N);
	if (arr == NULL)
	{
		perror("testShellSort->malloc failed");
		exit(-1);
	}
	/*if (arr2 == NULL)
	{
		perror("testShellSort->malloc failed");
		exit(-1);
	}*/
	for (int i = 0; i < N; i++)
	{
		arr[i] = rand() % 100;
		//arr2[i] = arr[i];
	}
	PrintArray(arr, N);
	SelectSort(arr, N);
	//ShellSort(arr, N);
	PrintArray(arr, N);
	
	free(arr);
	//free(arr2);
}
int main()
{
	srand((unsigned)time(NULL));
	test1();
	//test();
	//testQuickSort();
	//testStack();
	//testShellSort();
	return 0;
}







